package command.respondente;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import model.Respondente;

import command.ICommand;

import dao.RespondenteDAO;

public class ListarRespondentesCommand implements ICommand{

	public String execute(HttpServletRequest request) throws ServletException,IOException {
		RespondenteDAO dao = new RespondenteDAO();
		try {
			ArrayList<Respondente> respondentes = dao.listar();
			request.setAttribute("respondentes", respondentes);
			return "/paginas/respondente/listar_respondente.jsp";
		} catch (SQLException e) {
			e.printStackTrace();
			return "/paginas/tela_principal.jsp";
		}
	}

}
